package com.yilijk.base.network.https;

import com.yilijk.base.network.TypeUtils;

import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;

/**
 * Created by SHICHENG
 * <p>
 * Time on 2022/03/07
 */
public abstract class HttpCallBack<T> {

    public Type getSuperclassTypeParameter() {
        Type type = getClass().getGenericSuperclass();
        return TypeUtils.getParameterUpperBound(0, (ParameterizedType) type);
    }

    public abstract void onSuccess(T result, int code);

    public abstract void onFailure(String failureMsg, int statusCode);

    /**
     * onComplete 是在onFailure 或onSuccess之后调用
     * 如需在onFailure或onSuccess 关闭activity，请在关闭之前关闭dialog
     */
    public void onComplete() {

    }
}
